import { reactive } from "vue";
import type { FormRules } from "element-plus";

/** 自定义表单规则校验 */
export const formRules = reactive(<FormRules>{
  name: [{ required: true, message: "主机名称为必填项", trigger: "blur" }],
  hostname: [
    { required: true, message: "主机标识为必填项,且唯一", trigger: "blur" }
  ],
  private_ip_address: [
    {
      pattern:
        /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/,
      message: "请输入合法的IP地址",
      trigger: "blur"
    },
    { required: true, message: "内网IP地址为必填项", trigger: "blur" }
  ],
  public_ip_address: [
    {
      pattern:
        /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/,
      message: "请输入合法的IP地址",
      trigger: "blur"
    }
  ]
});
